import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const Home = () =>
  import('../views/home/Home')
const Task = () =>
  import('../views/task/Task')
const Community = () =>
  import('../views/community/Community')
const ClockIn = () =>
  import('../views/clockIn/ClockIn')
const Cooperate = () =>
  import('../views/cooperate/Cooperate')
const Gotime = () =>
  import('../views/home/home-components/Gotime')
const Login = () =>
  import('../views/login/Login')
const AddTask = () =>
  import('../views/home/home-components/AddTask')
// const AddPicture = () =>
//     import ('../views/profile/profile_child/AddPicture')

const routes = [{
  path: '',
  redirect: '/login'
},
{
  path: '/home',
  name: 'Home',
  component: Home
},
{
  path: '/task',
  name: 'Task',
  component: Task
},
{
  path: '/community',
  name: 'Community',
  component: Community
},
{
  path: '/clockIn',
  name: 'ClockIn',
  component: ClockIn
},
{
  path: '/cooperate',
  name: 'Cooperate',
  component: Cooperate
},
{
  path: '/gotime',
  name: 'Gotime',
  component: Gotime
},
{
  path: '/login',
  name:'login',
  component: Login
},
{
  path: '/addTask',
  name:'addTask',
  component: AddTask
},
  // {
  //     path: '/addpicture',
  //     component: AddPicture
  // }
]

const router = new VueRouter({
  routes,
  mode: 'history',
})


const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error)
}
const originalReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function replace(location) {
  return originalReplace.call(this, location).catch(err => err);
}

export default router